<?php

namespace App\Http\Resources;

use App\Common\CommonConst;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

class SysUserResource extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  Request              $request
     * @return array<string, mixed>
     */
    public function toArray(Request $request): array
    {
        return [
            'id' => $this->id,
            'username' => $this->username,
            'email' => $this->email,
            'mobile' => $this->mobile,
            'gender' => $this->gender,
            'gender_text' => CommonConst::$genderMap[$this->gender],
            'is_admin' => $this->is_admin,
            'department_id' => $this->department_id,
            'department_name' => $this->department_name,
            'creator' => $this->creator,
            'created_at' => $this->created_at->toDateTimeString(),
            'updated_at' => $this->updated_at->toDateTimeString(),
        ];
    }
}
